import request from '@/utils/request'
import qs from 'qs'

// 文章分类
export function getCategories(params) {
  return request({
    url: '/field/findList',
    method: 'post',
    params
  })
}

// 添加分类
export function addCategory(params) {
  return request({
    url: '/field/add',
    method: 'post',
    params
  })
}

// 编辑分类
export function updateCategory(params) {
  return request({
    url: '/field/update',
    method: 'post',
    params
  })
}

// 删除分类
export function removeCategory(params) {
  return request({
    url: '/field/delete',
    method: 'post',
    params
  })
}

// 文章分类置顶
export function categorySetTop(params) {
  return request({
    url: '/field/stick',
    method: 'post',
    params
  })
}

// 文章分类置底
export function categorySetBottom(params) {
  return request({
    url: '/field/bottom',
    method: 'post',
    params
  })
}

// 文章分类上移
export function categoryMoveUp(params) {
  return request({
    url: '/field/shift',
    method: 'post',
    params
  })
}

// 文章分类下移
export function categoryMoveDown(params) {
  return request({
    url: '/field/down',
    method: 'post',
    params
  })
}

// 文章列表
export function getArticles(params) {
  return request({
    url: '/content/findList',
    method: 'post',
    params
  })
}

// 文章详情
export function getArticleShow(params) {
  return request({
    url: '/content/queryInfo',
    method: 'get',
    params
  })
}

// 添加文章
export function addArticle(data) {
  const postData = qs.stringify(data)
  return request({
    url: '/content/add',
    method: 'post',
    data: postData
  })
}

// 编辑文章
export function updateArticle(data) {
  const postData = qs.stringify(data)
  return request({
    url: '/content/update',
    method: 'post',
    data: postData
  })
}

// 删除文章
export function removeArticle(params) {
  return request({
    url: '/content/delete',
    method: 'post',
    params
  })
}

// 文章置顶
export function articleSetTop(params) {
  return request({
    url: '/content/stick',
    method: 'post',
    params
  })
}

// 文章置底
export function articleSetBottom(params) {
  return request({
    url: '/content/bottom',
    method: 'post',
    params
  })
}

// 文章上移
export function articleMoveUp(params) {
  return request({
    url: '/content/shift',
    method: 'post',
    params
  })
}

// 文章下移
export function articleMoveDown(params) {
  return request({
    url: '/content/down',
    method: 'post',
    params
  })
}
